//
//  baseNavView.m
//  有材网
//
//  Created by 肖扬 on 16/1/26.
//  Copyright © 2016年 肖扬. All rights reserved.
//

#import "baseNavView.h"

@implementation baseNavView
@synthesize nav,left,right,title;
-(id)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.nav = [self createViewFrame:CGRectMake(0, 0, SWIDTH, 64) bgColor:UIColorFromRGB(0x247ac4) tag:0];
        [self addSubview:self.nav];
        UIButton *btn = [UIButton buttonWithType:0];
        btn.frame = CGRectMake(20, 36.5, 7, 14);
        [btn setBackgroundImage:[UIImage imageNamed:@"箭头"] forState:UIControlStateNormal];
        self.left = btn;
        [self addSubview:btn];
        self.title = [self createLabelFrame:CGRectMake(40, 20, SWIDTH - 80, 44) title:@"" titleColor:[UIColor whiteColor] tag:0];
        [self.title setTextAlignment:NSTextAlignmentCenter];
        [self addSubview:self.title];
    }
    return self;
}

//创建UILabel  tag值为三位数
- (UILabel *)createLabelFrame:(CGRect)frame
                        title:(NSString *)title
                   titleColor:(UIColor *)color
                          tag:(NSInteger)tag{
    UILabel *tempLabel = [[UILabel alloc]initWithFrame:frame];
    [tempLabel setBackgroundColor:[UIColor clearColor]];
    [tempLabel setText:title];
    [tempLabel setTag:tag];
    [tempLabel setTextColor:color];
    return tempLabel;
}
//创建UIButton tag值为四位数
- (UIButton *)createButtonFrame:(CGRect)frame
                          title:(NSString *)title
                 viewController:(id)viewController
                       selector:(SEL)selector
                            tag:(NSInteger)tag{
    UIButton *tempButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [tempButton setFrame:frame];
    [tempButton setTag:tag];
    [tempButton setBackgroundColor:[UIColor clearColor]];
    [tempButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [tempButton setTitle:title forState:UIControlStateNormal];
    [tempButton addTarget:viewController action:selector forControlEvents:UIControlEventTouchUpInside];
    return tempButton;
}
- (UIView *)createViewFrame:(CGRect)frame
                    bgColor:(UIColor *)color
                        tag:(NSInteger)tag{
    UIView *tempView = [[UIView alloc]initWithFrame:frame];
    [tempView setBackgroundColor:color];
    [tempView setTag:tag];
    return tempView;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
